from flask_appbuilder import Model
from sqlalchemy import Column, Integer, String, ForeignKey, Float
from sqlalchemy.orm import relationship
from myapp.models.base import MyappModelBase

class Model_Dependency(Model, MyappModelBase):
    __tablename__ = 'model_dependency'
    
    id = Column(Integer, primary_key=True)
    source_model_id = Column(Integer, ForeignKey('model.id'), comment='源模型ID')
    target_model_id = Column(Integer, ForeignKey('model.id'), comment='目标模型ID')
    dependency_type = Column(String(50), comment='依赖类型：data/model/feature')
    dependency_strength = Column(Float, default=1.0, comment='依赖强度')
    description = Column(String(500), comment='依赖描述')
    
    source_model = relationship('Training_Model', foreign_keys=[source_model_id])
    target_model = relationship('Training_Model', foreign_keys=[target_model_id])